package com.uhylab.uhuvinetest;

import android.content.Context;

import com.google.gson.Gson;
import com.uhylab.uhuvinetest.bean.HealthBean;
import com.uhylab.uhuvinetest.utils.AppJsonFileReader;

import java.util.List;

/**
 * Created by xyb on 16/1/16 at UHylab
 *
 * @version 1.0
 */
public class JNIJson {
    private List<HealthBean.AscorbicAcidEntity> ascorbicAcid;
    List<HealthBean.BilirubinEntity> bilirubin;
    List<HealthBean.BloodEntity> blood;
    List<HealthBean.GlucoseEntity> glucose;
    List<HealthBean.KetonesEntity> ketones;
    List<HealthBean.LeukocytesEntity> leukocytes;
    List<HealthBean.NitriteEntity> nitrite;
    List<HealthBean.PhEntity> ph;
    List<HealthBean.ProteinEntity> protein;
    List<HealthBean.SpecificGravityEntity> specificGravity;
    List<HealthBean.UrobilinogenEntity> urobilinogen;


    public JNIJson(Context context) {
        String jsonStr = AppJsonFileReader.getJson(context,
                "compareStandard.json");
        Gson gson = new Gson();
        HealthBean healthBean = gson.fromJson(jsonStr, HealthBean.class);
        ascorbicAcid = healthBean.getAscorbicAcid();
        bilirubin = healthBean.getBilirubin();
        blood = healthBean.getBlood();
        glucose = healthBean.getGlucose();
        ketones = healthBean.getKetones();
        leukocytes = healthBean.getLeukocytes();
        nitrite = healthBean.getNitrite();
        ph = healthBean.getPh();
        protein = healthBean.getProtein();
        specificGravity = healthBean.getSpecificGravity();
        urobilinogen = healthBean.getUrobilinogen();

    }


    public List<HealthBean.AscorbicAcidEntity> getAscorbicAcid() {
        return ascorbicAcid;
    }

    public List<HealthBean.BilirubinEntity> getBilirubin() {
        return bilirubin;
    }

    public List<HealthBean.BloodEntity> getBlood() {
        return blood;
    }

    public List<HealthBean.GlucoseEntity> getGlucose() {
        return glucose;
    }

    public List<HealthBean.KetonesEntity> getKetones() {
        return ketones;
    }

    public List<HealthBean.LeukocytesEntity> getLeukocytes() {
        return leukocytes;
    }

    public List<HealthBean.NitriteEntity> getNitrite() {
        return nitrite;
    }

    public List<HealthBean.PhEntity> getPh() {
        return ph;
    }

    public List<HealthBean.ProteinEntity> getProtein() {
        return protein;
    }

    public List<HealthBean.SpecificGravityEntity> getSpecificGravity() {
        return specificGravity;
    }

    public List<HealthBean.UrobilinogenEntity> getUrobilinogen() {
        return urobilinogen;
    }

    public float[] getS() {
        float[] s = new float[leukocytes.size()];
        for (int j = 0; j < leukocytes.size(); j++) {
            String h = leukocytes.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory : (imghistory + 360);
                s[j] = v;
            } catch (Exception e) {
            }
        }
        return s;
    }

    public float[] getNis() {
        float[] nis = new float[nitrite.size()];
        for (int j = 0; j < nitrite.size(); j++) {
            String h = nitrite.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                nis[j] = v;
            } catch (Exception e) {
            }
        }
        return nis;
    }

    public float[] getUrs() {
        float[] urs = new float[urobilinogen.size()];
        for (int j = 0; j < urobilinogen.size(); j++) {
            String h = urobilinogen.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                urs[j] = v;
            } catch (Exception e) {
            }
        }
        return urs;
    }

    public float[] getPhs() {
        float[] phs = new float[ph.size()];
        for (int j = 0; j < ph.size(); j++) {
            String h = ph.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                phs[j] = v;
            } catch (Exception e) {
            }
        }
        return phs;
    }

    public float[] getPrs() {
        float[] prs = new float[protein.size()];
        for (int j = 0; j < protein.size(); j++) {
            String h = protein.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory ;

                prs[j] = v;
            } catch (Exception e) {
            }
        }
        return prs;
    }

    public float[] getBls() {
        float[] bls = new float[blood.size()];
        for (int j = 0; j < blood.size(); j++) {
            String h = blood.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                bls[j] = v;
            } catch (Exception e) {
            }
        }
        return bls;
    }

    public float[] getSpecifis() {
        float[] specifis = new float[specificGravity.size()];
        for (int j = 0; j < specificGravity.size(); j++) {
            String h = specificGravity.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                specifis[j] = v;
            } catch (Exception e) {
            }
        }
        return specifis;
    }

    public float[] getKes() {
        float[] kes = new float[ketones.size()];
        for (int j = 0; j < ketones.size(); j++) {
            String h = ketones.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                kes[j] = v;
            } catch (Exception e) {
            }
        }
        return kes;
    }

    public float[] getBis() {
        float[] bis = new float[bilirubin.size()];
        for (int j = 0; j < bilirubin.size(); j++) {
            String h = bilirubin.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;

                bis[j] = v;
            } catch (Exception e) {
            }
        }
        return bis;
    }

    public float[] getGls() {
        float[] gls = new float[glucose.size()];
        for (int j = 0; j < glucose.size(); j++) {
            String h = glucose.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory  ;
                gls[j] = v;
            } catch (Exception e) {
            }
        }
        return gls;
    }

    public float[] getAss() {
        float[] ass = new float[ascorbicAcid.size()];
        for (int j = 0; j < ascorbicAcid.size(); j++) {
            String h = ascorbicAcid.get(j).getH();
            try {
                float imghistory = Float.parseFloat(h);
                float v = imghistory > 180 ? imghistory  : (imghistory + 360) ;
                ass[j] = v;
            } catch (Exception e) {
            }
        }
        return ass;
    }
}
